package cpt202.project.service.impl;
import cpt202.project.dao.BookMapper;
import cpt202.project.dao.RecordMapper;
import cpt202.project.entity.Book;
import cpt202.project.entity.Record;
import cpt202.project.service.InitialUserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class InitialUserinfoimpl implements InitialUserInfo {
    @Autowired
    private BookMapper bookMapper;
    @Autowired
    private RecordMapper recordMapper;

    @Override
    //返回默认账本里的records
    public Record[] retRec(String email) {
        Integer bookid = retDefBid(email);
       Record[] records = recordMapper.userRecord(bookid);
       return records;
    }

    @Override
    public Integer retDefBid(String email){
        Integer bookid = bookMapper.getDefaultBid(email);
        return bookid;
    }

    @Override
    //返回指定email下的所有accountbook的信息,返回形式是数组
    public Book[] retAllBid(String email) {
        Book[] userbook = bookMapper.getAllBid(email);
        return userbook;
    }
}
